Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement optimize(size) and optimize(speed) attributes #55641

Merged
merged 5 commits into from
Jan 26, 2019

Conversation

nagisa
Copy link
Member

@nagisa nagisa commented Nov 3, 2018

This PR implements both optimize(size) and optimize(speed) attributes.

While the functionality itself works fine now, this PR is not yet complete: the code might be messy in places and, most importantly, the compiletest must be improved with functionality to run tests with custom optimization levels. Otherwise the new attribute cannot be tested properly. Oh, and not all of the RFC is implemented – attribute propagation is not implemented for example.

TODO

  • Improve compiletest so that tests can be written;
  • Assign a proper error number (E9999 currently, no idea how to allocate a number properly);
  • Perhaps reduce the duplication in LLVM attribute assignment code…

@rust-highfive
Copy link
Collaborator

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 3, 2018
@nagisa
Copy link
Member Author

nagisa commented Nov 3, 2018

cc #54882

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:009315a3:start=1541237044741724763,finish=1541237046948850037,duration=2207125274
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
travis_time:start:tidy
tidy check
[00:03:49] * 568 error codes
[00:03:49] * highest error code: E9999
[00:03:50] tidy error: Found 1 features without a gate test.
[00:03:50] Expected a gate test for the feature 'optimize_attribute'.
[00:03:50] Hint: create a failing test file named 'feature-gate-optimize_attribute.rs'
[00:03:50]       in the 'ui' test suite, with its failures due to
[00:03:50]       missing usage of #![feature(optimize_attribute)].
[00:03:50] Hint: If you already have such a test and don't want to rename it,
[00:03:50]       you can also add a // gate-test-optimize_attribute line to the test file.
[00:03:50] some tidy checks failed
[00:03:50] 
[00:03:50] 
[00:03:50] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:50] 
[00:03:50] 
[00:03:50] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:50] Build completed unsuccessfully in 0:00:47
[00:03:50] Build completed unsuccessfully in 0:00:47
[00:03:50] Makefile:79: recipe for target 'tidy' failed
[00:03:50] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:04133410
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:29a33223:start=1541237288665578516,finish=1541237288669755760,duration=4177244
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0d79e220
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0014bf32
travis_time:start:0014bf32
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0ca39a44
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

// If any of the items require optimize(speed), we must use speed optimisation globally
// and set either `optnone` or corresponding size-oriented optimisation level for the
// rest of the items in the crate. Those attributes are set specifically
for_speed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that this will have some unintended fallout. While function passes are going to skip optnone functions, we'll also end up populating a full module pass manager, where likely not all module passes will ignore optnone functions (not to mention non-functions -- I don't believe there is an optnone for global variables.) Marking a single function for optimize(speed) may end up influencing codegen for the whole crate in non-trivial ways.

Copy link
Member Author

@nagisa nagisa Nov 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a known caveat. Alas, to get optimize(speed) (or optimize(speed), now that I think about it) to work as intended, it is necessary to initialize some sort of pass manager.

Are you saying it is possible to have separate managers for functions and the rest of the module? That might be a better approach then.

Copy link
Member Author

@nagisa nagisa Nov 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative is to have these attributes not work with -Copt-level=0 at all, but that is not what I intended when I wrote the RFC.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you saying it is possible to have separate managers for functions and the rest of the module? That might be a better approach then.

As far as I'm aware that's not possible. While LLVM has a separate function pass manager, it is only used for a few early optimizations, the bulk of the work (including most function passes) are performed by the module pass manager.

Alternative is to have these attributes to not work with -Copt-level=0 at all, but that is not what I intended when I wrote the RFC.

This would probably be the most predictable approach. It would make optimize(size) control the optsize attribute and optimize(speed) an opt-out for the optsize attribute (which, having looked at the RFC thread now, appears to be the motivation for having it). Either attribute would have no impact on global codegen, which is still controlled by -C opt-level. -C opt-level=0 would continue to mean "don't touch my code".

@bors
Copy link
Contributor

bors commented Nov 4, 2018

☔ The latest upstream changes (presumably #55349) made this pull request unmergeable. Please resolve the merge conflicts.

@pnkfelix
Copy link
Member

pnkfelix commented Nov 5, 2018

(What's here so far seems fine to me. Of course its WIP and it sounds like there may be future changes that will also need review.)

@pnkfelix pnkfelix added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 5, 2018
@pnkfelix
Copy link
Member

pnkfelix commented Nov 7, 2018

The weakness of compiletest as documented in the description is related (at least tangentially) to #55757

@TimNN
Copy link
Contributor

TimNN commented Nov 13, 2018

Ping from triage @nagisa: What is the status of this PR?

@nagisa
Copy link
Member Author

nagisa commented Nov 13, 2018

I’ll get back to this as soon as I get the other tasks off my plate and time onto it :)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:025316be:start=1542563866528197442,finish=1542563867660478479,duration=1132281037
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
travis_time:start:tidy
tidy check
[00:04:09] * 569 error codes
[00:04:09] * highest error code: E9999
[00:04:09] tidy error: Found 1 features without a gate test.
[00:04:09] Expected a gate test for the feature 'optimize_attribute'.
[00:04:09] Hint: create a failing test file named 'feature-gate-optimize_attribute.rs'
[00:04:09]       in the 'ui' test suite, with its failures due to
[00:04:09]       missing usage of #![feature(optimize_attribute)].
[00:04:09] Hint: If you already have such a test and don't want to rename it,
[00:04:09]       you can also add a // gate-test-optimize_attribute line to the test file.
[00:04:10] some tidy checks failed
[00:04:10] 
[00:04:10] 
[00:04:10] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:10] 
[00:04:10] 
[00:04:10] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:10] Build completed unsuccessfully in 0:00:43
[00:04:10] Build completed unsuccessfully in 0:00:43
[00:04:10] Makefile:79: recipe for target 'tidy' failed
[00:04:10] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:04e66bd9
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sun Nov 18 18:02:06 UTC 2018
---
travis_time:end:030b2d33:start=1542564127238716706,finish=1542564127243395009,duration=4678303
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:2fe813f3
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:02f277c2
travis_time:start:02f277c2
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:06d9b8cc
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:03445018:start=1542571687416275752,finish=1542571689995099888,duration=2578824136
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
travis_time:start:tidy
tidy check
[00:04:01] * 569 error codes
[00:04:01] * highest error code: E9999
[00:04:01] Expected a gate test for the feature 'optimize_attribute'.
[00:04:01] tidy error: Found 1 features without a gate test.
[00:04:01] Hint: create a failing test file named 'feature-gate-optimize_attribute.rs'
[00:04:01]       in the 'ui' test suite, with its failures due to
[00:04:01]       missing usage of #![feature(optimize_attribute)].
[00:04:01] Hint: If you already have such a test and don't want to rename it,
[00:04:01]       you can also add a // gate-test-optimize_attribute line to the test file.
[00:04:02] some tidy checks failed
[00:04:02] 
[00:04:02] 
[00:04:02] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:02] 
[00:04:02] 
[00:04:02] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:02] Build completed unsuccessfully in 0:00:53
[00:04:02] Build completed unsuccessfully in 0:00:53
[00:04:02] make: *** [tidy] Error 1
[00:04:02] Makefile:79: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:19464ff0
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sun Nov 18 20:12:22 UTC 2018
---
travis_time:end:009d05e4:start=1542571943258485377,finish=1542571943265865767,duration=7380390
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0386dedc
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0153f7c0
travis_time:start:0153f7c0
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:024659a0
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:11e078a8:start=1543165258662792543,finish=1543165260971378223,duration=2308585680
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
travis_time:start:tidy
tidy check
[00:03:01] * 569 error codes
[00:03:01] * highest error code: E9999
[00:03:01] tidy error: Found 1 features without a gate test.
[00:03:01] Expected a gate test for the feature 'optimize_attribute'.
[00:03:01] Hint: create a failing test file named 'feature-gate-optimize_attribute.rs'
[00:03:01]       in the 'ui' test suite, with its failures due to
[00:03:01]       missing usage of #![feature(optimize_attribute)].
[00:03:01] Hint: If you already have such a test and don't want to rename it,
[00:03:01]       you can also add a // gate-test-optimize_attribute line to the test file.
[00:03:02] some tidy checks failed
[00:03:02] 
[00:03:02] 
[00:03:02] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:02] 
[00:03:02] 
[00:03:02] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:02] Build completed unsuccessfully in 0:00:56
[00:03:02] Build completed unsuccessfully in 0:00:56
[00:03:02] Makefile:79: recipe for target 'tidy' failed
[00:03:02] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:13bc2fb6
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sun Nov 25 17:04:12 UTC 2018
---
travis_time:end:143006b0:start=1543165452898384025,finish=1543165452903479782,duration=5095757
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:08c2bb24
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0b2352f1
travis_time:start:0b2352f1
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:126bd930
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:018b87af:start=1543168873127460606,finish=1543168874279320257,duration=1151859651
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:50:32] .................................................................................................... 100/5053
[00:50:35] .................................................................................................... 200/5053
[00:50:38] .............................ii............................................ii...................ii.. 300/5053
[00:50:41] ..............................................................................................iii... 400/5053
[00:50:44] .....iiiiiiii.iii............................iii...........................................i........ 500/5053
[00:50:51] .................................................................................................... 700/5053
[00:50:56] .....................................................................................i...........i.. 800/5053
[00:51:00] .................................................................................................... 900/5053
[00:51:03] ....iiiii..................ii.iiii.................................................................. 1000/5053
---
travis_time:start:test_codegen
Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:06:01] 
[01:06:01] running 120 tests
[01:06:04] i..ii...iii..iiii.....i...i.........i..iii...........i.....i........ii...i..i.ii..............i...ii 100/120
[01:06:05] ..ii.i.....i.iii....
[01:06:05] 
[01:06:05]  finished in 3.534
[01:06:05] travis_fold:end:test_codegen

---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:06:19] 
[01:06:19] running 118 tests
[01:06:44] .iiiii...i.....i..i...i..i.i..i.i..i.....i..i....i..........iiii.........i.i....i...i.......ii.i.i.i 100/118
[01:06:48] ......iii.i.....ii
[01:06:48] 
[01:06:48]  finished in 28.524
[01:06:48] travis_fold:end:test_debuginfo

---
travis_time:start:test_run-make-fulldeps
Check compiletest suite=run-make-fulldeps mode=run-make (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:39:23] 
[01:39:23] running 192 tests
[01:39:50] .....................................................F.............................................. 100/192
[01:40:46] ...........................................................................................test [run-make] run-make-fulldeps/long-linker-command-lines has been running for over 60 seconds
[01:41:34] failures:
[01:41:34] 
[01:41:34] ---- [run-make] run-make-fulldeps/inline-always-many-cgu stdout ----
[01:41:34] 
[01:41:34] 
[01:41:34] error: make failed
[01:41:34] status: exit code: 2
[01:41:34] command: "make"
[01:41:34] stdout:
[01:41:34] ------------------------------------------
[01:41:34] make[1]: Entering directory '/checkout/src/test/run-make-fulldeps/inline-always-many-cgu'
[01:41:34] LD_LIBRARY_PATH="/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make-fulldeps/inline-always-many-cgu/inline-always-many-cgu:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/lib:" '/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc' --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make-fulldeps/inline-always-many-cgu/inline-always-many-cgu -L /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make-fulldeps/inline-always-many-cgu/inline-always-many-cgu  foo.rs --emit llvm-ir -C codegen-units=2
[01:41:34] if cat /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make-fulldeps/inline-always-many-cgu/inline-always-many-cgu/*.ll | "/checkout/src/etc/cat-and-grep.sh" -e '\bcall\b'; then \
[01:41:34]  echo "found call instruction when one wasn't expected"; \
[01:41:34]  exit 1; \
[01:41:34] fi
[01:41:34] [[[ begin stdout ]]]
[01:41:34] ; ModuleID = 'foo.3a1fbbbh-cgu.0'
[01:41:34] source_filename = "foo.3a1fbbbh-cgu.0"
[01:41:34] target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
[01:41:34] target triple = "x86_64-unknown-linux-gnu"
[01:41:34] 
[01:41:34] ; foo::a::bar
[01:41:34] ; Function Attrs: noinline nonlazybind optnone uwtable
[01:41:34] define void @_ZN3foo1a3bar17h93d7ab41e03a35d6E() unnamed_addr #0 {
[01:41:34]   ret void
[01:41:34] }
[01:41:34] 
[01:41:34] 
[01:41:34] attributes #0 = { noinline nonlazybind optnone uwtable "probe-stack"="__rust_probestack" }
[01:41:34] 
[01:41:34] !llvm.module.flags = !{!0}
[01:41:34] 
[01:41:34] !0 = !{i32 2, !"RtLibUseGOT", i32 1}
[01:41:34] ; ModuleID = 'foo.3a1fbbbh-cgu.1'
[01:41:34] source_filename = "foo.3a1fbbbh-cgu.1"
[01:41:34] target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
[01:41:34] target triple = "x86_64-unknown-linux-gnu"
[01:41:34] 
[01:41:34] ; foo::a::foo
[01:41:34] ; Function Attrs: noinline nonlazybind optnone uwtable
[01:41:34] define internal void @_ZN3foo1a3foo17h4934260c56dc6ae5E() unnamed_addr #0 {
[01:41:34]   ret void
[01:41:34] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:503:22
[01:41:34] }
[01:41:34] 
[01:41:34] 
[01:41:34] ; Function Attrs: noinline nonlazybind optnone uwtable
[01:41:34] define void @bar() unnamed_addr #0 {
[01:41:34] start:
[01:41:34] ; call foo::a::foo
[01:41:34]   call void @_ZN3foo1a3foo17h4934260c56dc6ae5E()
[01:41:34]   br label %bb1
[01:41:34] 
[01:41:34] bb1:                                              ; preds = %start
[01:41:34]   ret void
[01:41:34] }
[01:41:34] 
[01:41:34] attributes #0 = { noinline nonlazybind optnone uwtable "probe-stack"="__rust_probestack" }
[01:41:34] 
[01:41:34] !llvm.module.flags = !{!0}
[01:41:34] 
[01:41:34] !0 = !{i32 2, !"RtLibUseGOT", i32 1}
[01:41:34] 
[01:41:34] [[[ end stdout ]]]
[01:41:34] found call instruction when one wasn't expected
[01:41:34] Makefile:4: recipe for target 'all' failed
[01:41:34] make[1]: Leaving directory '/checkout/src/test/run-make-fulldeps/inline-always-many-cgu'
[01:41:34] ------------------------------------------
[01:41:34] stderr:
[01:41:34] ------------------------------------------
[01:41:34] ------------------------------------------
[01:41:34] warning: ignoring emit path because multiple .ll files were produced
[01:41:34] 
[01:41:34] make[1]: *** [all] Error 1
[01:41:34] ------------------------------------------
[01:41:34] 
[01:41:34] thread '[run-make] run-make-fulldeps/inline-always-many-cgu' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3324:9
[01:41:34] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[01:41:34] test result: FAILED. 191 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
[01:41:34] 
[01:41:34] 
[01:41:34] 
[01:41:34] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--rustdoc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "--src-base" "/checkout/src/test/run-make-fulldeps" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make-fulldeps" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-make" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "5.0.0\n" "--system-llvm" "--cc" "cc" "--cxx" "c++" "--cflags" "-ffunction-sections -fdata-sections -fPIC -m64" "--llvm-components" "aarch64 aarch64asmparser aarch64asmprinter aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils all all-targets amdgpu amdgpuasmparser amdgpuasmprinter amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo amdgpuutils analysis arm armasmparser armasmprinter armcodegen armdesc armdisassembler arminfo asmparser asmprinter binaryformat bitreader bitwriter bpf bpfasmprinter bpfcodegen bpfdesc bpfdisassembler bpfinfo codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfomsf debuginfopdb demangle dlltooldriver engine executionengine globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interpreter ipo irreader lanai lanaiasmparser lanaiasmprinter lanaicodegen lanaidesc lanaidisassembler lanaiinfo libdriver lineeditor linker lto mc mcdisassembler mcjit mcparser mips mipsasmparser mipsasmprinter mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmprinter msp430codegen msp430desc msp430info native nativecodegen nvptx nvptxasmprinter nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcjit passes powerpc powerpcasmparser powerpcasmprinter powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata runtimedyld scalaropts selectiondag sparc sparcasmparser sparcasmprinter sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzasmprinter systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target transformutils vectorize x86 x86asmparser x86asmprinter x86codegen x86desc x86disassembler x86info x86utils xcore xcoreasmprinter xcorecodegen xcoredesc xcoredisassembler xcoreinfo" "--llvm-cxxflags" "-I/usr/lib/llvm-5.0/include -std=c++0x -fuse-ld=gold -Wl,--no-keep-files-mapped -Wl,--no-map-whole-files -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -DNDEBUG -g1  -fno-exceptions -DLLVM_BUILD_GLOBAL_ISEL -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS" "--ar" "ar" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:41:34] 
[01:41:34] 
[01:41:34] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:41:34] Build completed unsuccessfully in 0:54:54
[01:41:34] Build completed unsuccessfully in 0:54:54
[01:41:34] Makefile:58: recipe for target 'check' failed
[01:41:34] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:01bec35c
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sun Nov 25 19:42:57 UTC 2018
---
travis_time:end:03323db1:start=1543174983141873234,finish=1543174983149887054,duration=8013820
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0f711d4d
$ ln -s . checkout && for CORE in obj/cores/core.*;

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nagisa
Copy link
Member Author

nagisa commented Nov 25, 2018

The failing test seems to be invalid. Namely, it seems that the test is compiling with optimisations disabled and yet checking for inline(always) which is no-op in that case.

cc @alexcrichton do you know/remember why the test is compiled without optimisations? Will the test be just as valid if I slap a -Copt-level=1 on it’s rustc invocations?

@alexcrichton
Copy link
Member

I think that's a test that #[inline(always)] is respected in all modes, including opt-level=0. Did this PR break that though?

@nagisa
Copy link
Member Author

nagisa commented Nov 26, 2018 via email

@alexcrichton
Copy link
Member

We well the intention of the test is that we do respect the inline always attribute at O0, and we do execute the necessary passes to handle inline always functions. I don't believe this is functionality that we can break, crates rely on this in the wild

@nagisa
Copy link
Member Author

nagisa commented Nov 26, 2018

Ah, okay, makes sense. I’m slightly surprised we run any passes at -Copt-level=0, but then it also makes sense that we do. I’ll just have to change approach in this PR with that in mind.

@bors
Copy link
Contributor

bors commented Nov 30, 2018

☔ The latest upstream changes (presumably #49219) made this pull request unmergeable. Please resolve the merge conflicts.

@nagisa nagisa changed the title [WIP] Implement optimize(size) and optimize(speed) attributes Implement optimize(size) and optimize(speed) attributes Dec 1, 2018
@nagisa
Copy link
Member Author

nagisa commented Dec 1, 2018

I think this is ready-to-merge now. Perhaps it would have been a great idea to add support for revisions for codegen tests in a separate PR… but hey, it is now possible to have tests with their own optimisation levels! It might be sensible to open up revisions to other test types as well (which should be just removal of the panic/assertion away).

@alexcrichton I used the new revisions support for codegen tests added in this PR to write a proper test for the inline(always) in -Copt-level=0. You can see it at src/test/codegen/inline-always-works-always.rs.

@stokhos
Copy link

stokhos commented Jan 14, 2019

Ping from triage @nagisa : Have you been able to make any progress on this?

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0f2c8ce2:start=1547849684232225209,finish=1547849758287757033,duration=74055531824
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
    100% |████████████████████████████████| 51kB 23.0MB/s 
Collecting colorama<=0.3.9,>=0.2.5 (from awscli)
  Downloading https://files.pythonhosted.org/packages/db/c8/7dcf9dbcb22429512708fe3a547f8b6101c0d02137acbd892505aee57adf/colorama-0.3.9-py2.py3-none-any.whl
Collecting botocore==1.12.82 (from awscli)
  Downloading https://files.pythonhosted.org/packages/ee/3a/2c1ef0f7d9f13db88a3b1475bfc0eafacfd9e5a622ecf8fb34ffb0c33fe3/botocore-1.12.82-py2.py3-none-any.whl (5.2MB)
    0% |▏                               | 20kB 22.5MB/s eta 0:00:01
    0% |▏                               | 30kB 26.6MB/s eta 0:00:01
    0% |▎                               | 40kB 29.7MB/s eta 0:00:01
    0% |▎                               | 51kB 31.7MB/s eta 0:00:01
---

[00:03:33] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:34] tidy error: /checkout/src/test/ui/feature-gate-optimize_attribute.rs:1: copyright notices attributed to the Rust Project Developers are deprecated
[00:03:34] tidy error: duplicate error code: 720
[00:03:34] tidy error: /checkout/src/librustc_typeck/diagnostics.rs:4623: E0720: r##"
[00:03:34] tidy error: /checkout/src/librustc_typeck/diagnostics.rs:4722:     E0720, // Malformed #[optimize] attribute
[00:03:35] some tidy checks failed
[00:03:35] 
[00:03:35] 
[00:03:35] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:35] 
[00:03:35] 
[00:03:35] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:35] Build completed unsuccessfully in 0:00:48
[00:03:35] Build completed unsuccessfully in 0:00:48
[00:03:35] make: *** [tidy] Error 1
[00:03:35] Makefile:69: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:311b8033
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Fri Jan 18 22:19:42 UTC 2019
---
travis_time:end:0a39db9a:start=1547849983527698991,finish=1547849983532948817,duration=5249826
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0007dd66
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:02e93ef5
travis_time:start:02e93ef5
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0886b211
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:284e1d7a:start=1547852819804413782,finish=1547852893006242552,duration=73201828770
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
    100% |████████████████████████████████| 51kB 22.1MB/s 
Collecting colorama<=0.3.9,>=0.2.5 (from awscli)
  Downloading https://files.pythonhosted.org/packages/db/c8/7dcf9dbcb22429512708fe3a547f8b6101c0d02137acbd892505aee57adf/colorama-0.3.9-py2.py3-none-any.whl
Collecting botocore==1.12.82 (from awscli)
  Downloading https://files.pythonhosted.org/packages/ee/3a/2c1ef0f7d9f13db88a3b1475bfc0eafacfd9e5a622ecf8fb34ffb0c33fe3/botocore-1.12.82-py2.py3-none-any.whl (5.2MB)
    0% |▏                               | 20kB 22.1MB/s eta 0:00:01
    0% |▏                               | 30kB 23.5MB/s eta 0:00:01
    0% |▎                               | 40kB 26.6MB/s eta 0:00:01
    0% |▎                               | 51kB 29.8MB/s eta 0:00:01
---

[00:03:24] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:25] tidy error: /checkout/src/test/ui/feature-gate-optimize_attribute.rs:1: copyright notices attributed to the Rust Project Developers are deprecated
[00:03:26] some tidy checks failed
[00:03:26] 
[00:03:26] 
[00:03:26] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:26] 
[00:03:26] 
[00:03:26] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:26] Build completed unsuccessfully in 0:00:45
[00:03:26] Build completed unsuccessfully in 0:00:45
[00:03:26] make: *** [tidy] Error 1
[00:03:26] Makefile:69: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:06a14360
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Fri Jan 18 23:11:48 UTC 2019
---
travis_time:end:1732e7f8:start=1547853108869423163,finish=1547853108873876225,duration=4453062
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0df45b70
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:10bf6900
travis_time:start:10bf6900
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:05774510
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors
Copy link
Contributor

bors commented Jan 19, 2019

☔ The latest upstream changes (presumably #57747) made this pull request unmergeable. Please resolve the merge conflicts.

@pnkfelix pnkfelix added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 24, 2019
@@ -65,15 +65,24 @@ fn declare_raw_fn(
}
}

match cx.tcx.sess.opts.cg.opt_level.as_ref().map(String::as_ref) {
Some("s") => {
// FIXME(opt): this is kinda duplicated with similar code in attributes::from_fm_attrs…
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are in the same crate; can we lift it out to a common method? Or is there some difference I'm missing...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(some things are different in what we call for e.g. Speed; cannot tell offhand if that is actually significant or not. So I guess this can stay as is for now.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extracted the common code into a function.

@pnkfelix pnkfelix closed this Jan 24, 2019
@pnkfelix pnkfelix reopened this Jan 24, 2019
@pnkfelix
Copy link
Member

okay r=me after a rebase. I trust @nagisa has a good reason for not lifting the match with the "kinda duplicated" out into a helper.

Alas it does not currently work, because of limitations in compiletest…
`compile-flags: -Copt-level` will avoid adding -O. Similarly for -g and
-Cdebuglevel.
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:157f22a0:start=1548367477454092862,finish=1548367480118074125,duration=2663981263
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[01:06:53] ii.................................................................................................. 1100/5327
[01:06:55] .................................................................................................... 1200/5327
[01:06:58] .................................................................................................... 1300/5327
[01:07:01] .................................................................................................... 1400/5327
[01:07:03] .....................F.............................................................................. 1500/5327
[01:07:09] ..............................................................i..................................... 1700/5327
[01:07:13] .................................................................................................... 1800/5327
[01:07:17] .................................................................................................... 1900/5327
[01:07:20] .................................................................................................... 2000/5327
---
[01:09:30] 
[01:09:30] ---- [ui] ui/feature-gate-optimize_attribute.rs stdout ----
[01:09:30] diff of stderr:
[01:09:30] 
[01:09:30] 1 error[E0658]: #[optimize] attribute is an unstable feature (see issue #54882)
[01:09:30] -   --> $DIR/feature-gate-optimize_attribute.rs:16:1
[01:09:30] +   --> $DIR/feature-gate-optimize_attribute.rs:7:1
[01:09:30] 3    |
[01:09:30] 4 LL | #[optimize(size)] //~ ERROR #54882
[01:09:30] 
[01:09:30] 
[01:09:30] 7    = help: add #![feature(optimize_attribute)] to the crate attributes to enable
[01:09:30] 8 
[01:09:30] 9 error[E0658]: #[optimize] attribute is an unstable feature (see issue #54882)
[01:09:30] -   --> $DIR/feature-gate-optimize_attribute.rs:19:1
[01:09:30] +   --> $DIR/feature-gate-optimize_attribute.rs:10:1
[01:09:30] 11    |
[01:09:30] 12 LL | #[optimize(speed)] //~ ERROR #54882
[01:09:30] 
[01:09:30] 
[01:09:30] 15    = help: add #![feature(optimize_attribute)] to the crate attributes to enable
[01:09:30] 16 
[01:09:30] 17 error[E0658]: #[optimize] attribute is an unstable feature (see issue #54882)
[01:09:30] -   --> $DIR/feature-gate-optimize_attribute.rs:22:1
[01:09:30] +   --> $DIR/feature-gate-optimize_attribute.rs:13:1
[01:09:30] 19    |
[01:09:30] 20 LL | #[optimize(banana)] //~ ERROR #54882
[01:09:30] 
[01:09:30] 
[01:09:30] 23    = help: add #![feature(optimize_attribute)] to the crate attributes to enable
[01:09:30] 24 
[01:09:30] 25 error[E0658]: #[optimize] attribute is an unstable feature (see issue #54882)
[01:09:30] -   --> $DIR/feature-gate-optimize_attribute.rs:13:1
[01:09:30] +   --> $DIR/feature-gate-optimize_attribute.rs:4:1
[01:09:30] 27    |
[01:09:30] 28 LL | #[optimize(size)] //~ ERROR #54882
[01:09:30] 
[01:09:30] 
[01:09:30] 31    = help: add #![feature(optimize_attribute)] to the crate attributes to enable
[01:09:30] 32 
[01:09:30] 33 error[E0658]: #[optimize] attribute is an unstable feature (see issue #54882)
[01:09:30] -   --> $DIR/feature-gate-optimize_attribute.rs:11:1
[01:09:30] +   --> $DIR/feature-gate-optimize_attribute.rs:2:1
[01:09:30] 35    |
[01:09:30] 36 LL | #![optimize(speed)] //~ ERROR #54882
[01:09:30] 
[01:09:30] 38    |
[01:09:30] 38    |
[01:09:30] 39    = help: add #![feature(optimize_attribute)] to the crate attributes to enable
[01:09:30] - error: aborting due to 5 previous errors
[01:09:30] + error[E0722]: invalid argument
[01:09:30] +   --> $DIR/feature-gate-optimize_attribute.rs:13:12
[01:09:30] +    |
[01:09:30] +    |
[01:09:30] + LL | #[optimize(banana)] //~ ERROR #54882
[01:09:30] 42 
[01:09:30] - For more information about this error, try `rustc --explain E0658`.
[01:09:30] + error: aborting due to 6 previous errors
[01:09:30] + 
[01:09:30] + 
[01:09:30] + Some errors occurred: E0658, E0722.
[01:09:30] + For more information about an error, try `rustc --explain E0658`.
[01:09:30] 44 
[01:09:30] 
[01:09:30] 
[01:09:30] The actual stderr differed from the expected stderr.
[01:09:30] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gate-optimize_attribute/feature-gate-optimize_attribute.stderr
[01:09:30] To update references, rerun the tests and pass the `--bless` flag
[01:09:30] To only update this specific test, also pass `--test-args feature-gate-optimize_attribute.rs`
[01:09:30] error: 1 errors occurred comparing output.
[01:09:30] status: exit code: 1
[01:09:30] status: exit code: 1
[01:09:30] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/feature-gate-optimize_attribute.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gate-optimize_attribute/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gate-optimize_attribute/auxiliary" "-A" "unused"
[01:09:30] ------------------------------------------
[01:09:30] 
[01:09:30] ------------------------------------------
[01:09:30] stderr:
[01:09:30] stderr:
[01:09:30] ------------------------------------------
[01:09:30] {"message":"#[optimize] attribute is an unstable feature (see issue #54882)","code":{"code":"E0658","explanation":"\nAn unstable feature was used.\n\nErroneous code example:\n\n```compile_fail,E658\n#[repr(u128)] // error: use of unstable library feature 'repr128'\nenum Foo {\n    Bar(u64),\n}\n```\n\nIf you're using a stable or a beta version of rustc, you won't be able to use\nany unstable features. In order to do so, please switch to a nightly version of\nrustc (by using rustup).\n\nIf you're using a nightly version of rustc, just add the corresponding feature\nto be able to use it:\n\n```\n#![feature(repr128)]\n\n#[repr(u128)] // ok!\nenum Foo {\n    Bar(u64),\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/feature-gate-optimize_attribute.rs","byte_start":109,"byte_end":126,"line_start":7,"line_end":7,"column_start":1,"column_end":18,"is_primary":true,"text":[{"text":"#[optimize(size)] //~ ERROR #54882","highlight_start":1,"highlight_end":18}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"add #![feature(optimize_attribute)] to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0658]: #[optimize] attribute is an unstable feature (see issue #54882)\n  --> /checkout/src/test/ui/feature-gate-optimize_attribute.rs:7:1\n   |\nLL | #[optimize(size)] //~ ERROR #54882\n   | ^^^^^^^^^^^^^^^^^\n   |\n   = help: add #![feature(optimize_attribute)] to the crate attributes to enable\n\n"}
[01:09:30] {"message":"#[optimize] attribute is an unstable feature (see issue #54882)","code":{"code":"E0658","explanation":"\nAn unstable feature was used.\n\nErroneous code example:\n\n```compile_fail,E658\n#[repr(u128)] // error: use of unstable library feature 'repr128'\nenum Foo {\n    Bar(u64),\n}\n```\n\nIf you're using a stable or a beta version of rustc, you won't be able to use\nany unstable features. In order to do so, please switch to a nightly version of\nrustc (by using rustup).\n\nIf you're using a nightly version of rustc, just add the corresponding feature\nto be able to use it:\n\n```\n#![feature(repr128)]\n\n#[repr(u128)] // ok!\nenum Foo {\n    Bar(u64),\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/feature-gate-optimize_attribute.rs","byte_start":158,"byte_end":176,"line_start":10,"line_end":10,"column_start":1,"column_end":19,"is_primary":true,"text":[{"text":"#[optimize(speed)] //~ ERROR #54882","highlight_start":1,"highlight_end":19}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"add #![feature(optimize_attribute)] to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0658]: #[optimize] attribute is an unstable feature (see issue #54882)\n  --> /checkout/src/test/ui/feature-gate-optimize_attribute.rs:10:1\n   |\nLL | #[optimize(speed)] //~ ERROR #54882\n   | ^^^^^^^^^^^^^^^^^^\n   |\n   = help: add #![feature(optimize_attribute)] to the crate attributes to enable\n\n"}
[01:09:30] {"message":"#[optimize] attribute is an unstable feature (see issue #54882)","code":{"code":"E0658","explanation":"\nAn unstable feature was used.\n\nErroneous code example:\n\n```compile_fail,E658\n#[repr(u128)] // error: use of unstable library feature 'repr128'\nenum Foo {\n    Bar(u64),\n}\n```\n\nIf you're using a stable or a beta version of rustc, you won't be able to use\nany unstable features. In order to do so, please switch to a nightly version of\nrustc (by using rustup).\n\nIf you're using a nightly version of rustc, just add the corresponding feature\nto be able to use it:\n\n```\n#![feature(repr128)]\n\n#[repr(u128)] // ok!\nenum Foo {\n    Bar(u64),\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/feature-gate-optimize_attribute.rs","byte_start":209,"byte_end":228,"line_start":13,"line_end":13,"column_start":1,"column_end":20,"is_primary":true,"text":[{"text":"#[optimize(banana)] //~ ERROR #54882","highlight_start":1,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"add #![feature(optimize_attribute)] to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0658]: #[optimize] attribute is an unstable feature (see issue #54882)\n  --> /checkout/src/test/ui/feature-gate-optimize_attribute.rs:13:1\n   |\nLL | #[optimize(banana)] //~ ERROR #54882\n   | ^^^^^^^^^^^^^^^^^^^\n   |\n   = help: add #![feature(optimize_attribute)] to the crate attributes to enable\n\n"}
[01:09:30] {"message":"#[optimize] attribute is an unstable feature (see issue #54882)","code":{"code":"E0658","explanation":"\nAn unstable feature was used.\n\nErroneous code example:\n\n```compile_fail,E658\n#[repr(u128)] // error: use of unstable library feature 'repr128'\nenum Foo {\n    Bar(u64),\n}\n```\n\nIf you're using a stable or a beta version of rustc, you won't be able to use\nany unstable features. In order to do so, please switch to a nightly version of\nrustc (by using rustup).\n\nIf you're using a nightly version of rustc, just add the corresponding feature\nto be able to use it:\n\n```\n#![feature(repr128)]\n\n#[repr(u128)] // ok!\nenum Foo {\n    Bar(u64),\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/feature-gate-optimize_attribute.rs","byte_start":60,"byte_end":77,"line_start":4,"line_end":4,"column_start":1,"column_end":18,"is_primary":true,"text":[{"text":"#[optimize(size)] //~ ERROR #54882","highlight_start":1,"highlight_end":18}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"add #![feature(optimize_attribute)] to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0658]: #[optimize] attribute is an unstable feature (see issue #54882)\n  --> /checkout/src/test/ui/feature-gate-optimize_attribute.rs:4:1\n   |\nLL | #[optimize(size)] //~ ERROR #54882\n   | ^^^^^^^^^^^^^^^^^\n   |\n   = help: add #![feature(optimize_attribute)] to the crate attributes to enable\n\n"}
[01:09:30] {"message":"#[optimize] attribute is an unstable feature (see issue #54882)","code":{"code":"E0658","explanation":"\nAn unstable feature was used.\n\nErroneous code example:\n\n```compile_fail,E658\n#[repr(u128)] // error: use of unstable library feature 'repr128'\nenum Foo {\n    Bar(u64),\n}\n```\n\nIf you're using a stable or a beta version of rustc, you won't be able to use\nany unstable features. In order to do so, please switch to a nightly version of\nrustc (by using rustup).\n\nIf you're using a nightly version of rustc, just add the corresponding feature\nto be able to use it:\n\n```\n#![feature(repr128)]\n\n#[repr(u128)] // ok!\nenum Foo {\n    Bar(u64),\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/feature-gate-optimize_attribute.rs","byte_start":22,"byte_end":41,"line_start":2,"line_end":2,"column_start":1,"column_end":20,"is_primary":true,"text":[{"text":"#![optimize(speed)] //~ ERROR #54882","highlight_start":1,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"add #![feature(optimize_attribute)] to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0658]: #[optimize] attribute is an unstable feature (see issue #54882)\n  --> /checkout/src/test/ui/feature-gate-optimize_attribute.rs:2:1\n   |\nLL | #![optimize(speed)] //~ ERROR #54882\n   | ^^^^^^^^^^^^^^^^^^^\n   |\n   = help: add #![feature(optimize_attribute)] to the crate attributes to enable\n\n"}
[01:09:30] {"message":"invalid argument","code":{"code":"E0722","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/feature-gate-optimize_attribute.rs","byte_start":220,"byte_end":226,"line_start":13,"line_end":13,"column_start":12,"column_end":18,"is_primary":true,"text":[{"text":"#[optimize(banana)] //~ ERROR #54882","highlight_start":12,"highlight_end":18}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0722]: invalid argument\n  --> /checkout/src/test/ui/feature-gate-optimize_attribute.rs:13:12\n   |\nLL | #[optimize(banana)] //~ ERROR #54882\n   |            ^^^^^^\n\n"}
[01:09:30] {"message":"aborting due to 6 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 6 previous errors\n\n"}
[01:09:30] {"message":"Some errors occurred: E0658, E0722.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0658, E0722.\n"}
[01:09:30] 
[01:09:30] ------------------------------------------
[01:09:30] 
[01:09:30] thread '[ui] ui/feature-gate-optimize_attribute.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3287:9
---
[01:09:30] 
[01:09:30] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:495:22
[01:09:30] 
[01:09:30] 
[01:09:30] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:09:30] 
[01:09:30] 
[01:09:30] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:09:30] Build completed unsuccessfully in 0:04:20
[01:09:30] Build completed unsuccessfully in 0:04:20
[01:09:30] Makefile:48: recipe for target 'check' failed
[01:09:30] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0cc37e9d
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu Jan 24 23:14:20 UTC 2019
---
travis_time:end:0e817fbe:start=1548371661824838449,finish=1548371661830150537,duration=5312088
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0a0e1221
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:06341596
travis_time:start:06341596
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0148ca64
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nagisa
Copy link
Member Author

nagisa commented Jan 25, 2019

@bors r=pnkfelix

Finally? Go! Go! Go!

@bors
Copy link
Contributor

bors commented Jan 25, 2019

📌 Commit ce289c6 has been approved by pnkfelix

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 25, 2019
@bors
Copy link
Contributor

bors commented Jan 26, 2019

⌛ Testing commit ce289c6 with merge 42eb5ff...

bors added a commit that referenced this pull request Jan 26, 2019
Implement optimize(size) and optimize(speed) attributes

This PR implements both `optimize(size)` and `optimize(speed)` attributes.

While the functionality itself works fine now, this PR is not yet complete: the code might be messy in places and, most importantly, the compiletest must be improved with functionality to run tests with custom optimization levels. Otherwise the new attribute cannot be tested properly. Oh, and not all of the RFC is implemented – attribute propagation is not implemented for example.

# TODO

* [x] Improve compiletest so that tests can be written;
* [x] Assign a proper error number (E9999 currently, no idea how to allocate a number properly);
* [ ] Perhaps reduce the duplication in LLVM attribute assignment code…
@bors
Copy link
Contributor

bors commented Jan 26, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: pnkfelix
Pushing 42eb5ff to master...

@bors
Copy link
Contributor

bors commented Jan 26, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: pnkfelix
Pushing 42eb5ff to master...

@bors bors merged commit ce289c6 into rust-lang:master Jan 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants